package com.itheima.mapper;

import com.itheima.pojo.PageResult;
import com.itheima.pojo.Student;
import com.itheima.pojo.dto.StudentsDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentsMapper {

    /**
     * 条件查询
     * @param studentsDto
     * @return
     */
    public List<Student> querySelect(StudentsDto studentsDto);

    /**
     * 新增学员
     * @param student
     */
    @Insert("insert into student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time) " +
            "values(#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void save(Student student);

    /**
     * 批量删除
     * @param ids
     */
    void deleteBatch(List<Integer> ids);

    /**
     * 修改学员信息
     * @param student
     */
    void update(Student student);

    /**
     * 学员学历统计
     * @return
     */
    @MapKey("name")
    List<Map<String, Object>> studentDegreeData();

    /**
     * 学员班级人数统计
     * @return
     */
    @MapKey("clazzList")
    List<Map<String, Object>> studentCountData();
}
